package com.huaxin.hxenum.validator;

import com.huaxin.hxenum.enums.Unit;
import com.huaxin.hxenum.validation.ValidUnit;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class UnitValidator implements ConstraintValidator<ValidUnit, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null || value.trim().isEmpty()) {
            return true;
        }
        return Unit.isValid(value);
    }
}